/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac4.only5.vo;

import edu.uoc.tdp.pac4.only5.domain.Resource;
import java.io.Serializable;

/**
 *
 * @author Gerard
 */
public class ResourceBookingVO implements Serializable {
    
    private Resource resource;
    
    private Integer booked;
    
    private Double priceBooked;

    public ResourceBookingVO() {
        
    }

    public ResourceBookingVO(Resource resource, Integer booked) {
        this.resource = resource;
        this.booked = booked;
    }

    public Integer getBooked() {
        return booked;
    }

    public void setBooked(Integer booked) {
        this.booked = booked;
    }

    public Resource getResource() {
        return resource;
    }

    public void setResource(Resource resource) {
        this.resource = resource;
    }
    
    public Double calculatePriceBooked(boolean isBookingAllDay){
        if(priceBooked == null  && booked != null) {
            if(isBookingAllDay && resource.getPrice_day() != null){
                 priceBooked = resource.getPrice_day() * booked;
            } else if(resource.getPrice_hour() != null) {
                 priceBooked = resource.getPrice_hour() * booked;
            }
        }
        return priceBooked;
    }
    

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb  .append(resource.getResource_desc())
            .append("qtt=" + booked);
        return sb.toString();
    }
    
    
    
}
